<template>
    <div>
        <template v-for="cmd in cmd_list">
            <el-button :key="cmd"
                       v-if="cmd === 'edit'"
                       type="text"
                       size="small"
                       @click="onClickCmd('edit')">
                编辑
            </el-button>
            <el-button :key="cmd"
                       v-else-if="cmd === 'delete'"
                       type="text"
                       size="small"
                       @click="onClickCmd('delete')">
                删除
            </el-button>
        </template>
    </div>
</template>

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';

@Component({ name: 'KTableAction' })
export default class KTableAction extends Vue {
    @Prop({ type: String }) readonly list!: string;
    @Prop({ type: Object }) readonly data!: any;

    get cmd_list() {
        return this.list.split(',');
    }

    mounted() {}

    onClickCmd(cmd: string) {
        this.$emit('command', cmd, this.data);
    }
}
</script>
